﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MenuDetail.aspx.cs" Inherits="admin_system_MenuDetail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="/admin/Css/Common.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jQuery1.7.js" type="text/javascript"></script>
    <script src="/Plugin/artDialog/jquery.artDialog.source.js?skin=blue" type="text/javascript"></script>
    <script src="/Plugin/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Plugin/Validform/js/Validform_v4.0.js" type="text/javascript"></script>
    <link href="/Plugin/Validform/css/style.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/sjn.1.js" type="text/javascript"></script>
    <script src="/Plugin/jqueryEasyui/jquery.easyui.min.js" type="text/javascript"></script>
    <link href="/Plugin/jqueryEasyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Plugin/jqueryEasyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        table tr
        {
            height:50px;
            line-height:50px;
        }
    </style>
    <script language="javascript" type="text/javascript">

        var editData = art.artDialog.data("editData");
        var win = art.dialog.open.origin;


        //页面加载
        $(function () {


            //初始化表单提交
            $(".registerform").Validform({
                tiptype: 2,
                postonce: true,
                ajaxPost: true,
                callback: function (data) {
                    if (data.status == "y") {
                        art.artDialog.alert(data.info);
                        win.$("#tg").treegrid("reload");
                        art.dialog.close();  //提交成功，关闭弹出框
                    } else {
                        art.artDialog.alert(data.info);
                    }
                }
            });

            //只绘制TreeGrid , TreeGrid的数据在Combobox数据加载完成后，初始化选择项目时onSelect中执行，
            $('#tg').treegrid({
                url: 'MenuList.aspx?fun=GetTreeNotInCurrent&cid=' + (editData == undefined ? "" : editData.ID),
                idField: 'ID',
                treeField: 'Name',
                height: $("#classList").height(),
                columns: [[
                        { title: '请选择所属父类', field: 'Name', width: 280 }
                    ]],
                onClickRow: tg_onClickRow,
                onLoadSuccess: function (row, data) {
                    if (data.length > 0) {
                        //编辑时，数据初始化
                        if (editData != null && editData != undefined) {
                            $("#C_Name").val(editData.Name);
                            $("#C_Url").val(editData.Url);
                            $("#C_Order").val(editData.Order);
                            $("#C_ID").val(editData.ID);
                            $('#tg').treegrid("select", editData.PID);
                            var r = $('#tg').treegrid("find", editData.PID);
                            tg_onClickRow(r);
                        } else {
                            //默认选择中第一行
                            $('#tg').treegrid("select", data[0].ID);
                            var r = $('#tg').treegrid("find", data[0].ID);
                            tg_onClickRow(r);
                        }
                    }
                }
            });

        });

        var btn_Submit = function () {
            $("form").submit();
        }

        //行 click事件
        var tg_onClickRow = function (row) {
            $("#Pname").val(row.Name);
            $("#C_Parent_ID").val(row.ID);
            $("#Pname").blur();
        }

        var myalert = function (obj) {
            //初始name和id存储器，为“ ”值，用于返回时，判断如果为" "说明没有选择父级菜单
            art.dialog.data("name", " ");
            art.dialog.data("id", " ");
            art.dialog.open('<%=MyUrl.ToAb("~/Admin/Dialog/") %>List.aspx?act=menualllist&cid=' + $("#C_ID").val(),
                            {
                                title: "选择所属菜单（双击选中）",
                                id: 'MenuList',
                                lock: true,
                                close: function () {
                                    if (art.dialog.data("name") != " " && art.dialog.data("id") != " ") {
                                        var classVal = art.dialog.data("name");
                                        var classValID = art.dialog.data("id");
                                        if (classVal != "null") {
                                            $(obj).val(classVal);
                                            $(obj).next().val(classValID);
                                            $(obj).trigger("blur");
                                        }
                                    }
                                }
                            });
        }
    </script>
</head>
<body>
    <form id="form1" class="registerform" runat="server">
    <div style="width: 790px;">
        <div id="classList" style="float: left; width: 300px; height: 300px;">
            <table id="tg" class="easyui-treegrid">
            </table>
        </div>
        <div style="float: left; width: 470px; clear: none; margin-left: 20px;">
            <table>
                <tr>
                    <td>
                        <span style="color: Red">*&nbsp;</span>所属父类：
                    </td>
                    <td style="padding-right: 7px;">
                        <input type="text" id="Pname" disabled="disabled" readonly="readonly" name="Pname"
                            class="inputxt" datatype="*1-40" nullmsg="请选择所属上级菜单" errormsg="长度为1~40，请输入正确的字符串长度"
                            style="width: 100%;" />
                        <input type="hidden" id="C_Parent_ID" name="C_Parent_ID" />
                    </td>
                    <td>
                        <div class="Validform_checktip">
                            请选择上级菜单
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span style="color: Red">*&nbsp;</span>菜单名称：
                    </td>
                    <td style="padding-right: 7px;">
                        <input type="text" id="C_Name" name="C_Name" class="inputxt" datatype="*1-40" nullmsg="请输入菜单名称！"
                            errormsg="长度为1~40的，请输入正确的字符串长度" style="width: 100%;" />
                    </td>
                    <td>
                        <div class="Validform_checktip">
                            请输入菜单名称
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span style="color: White">*&nbsp;</span>链接地址：
                    </td>
                    <td>
                        <textarea rows="4" id="C_Url" style="font-size: 12px;" name="C_Url" cols="25"></textarea>
                    </td>
                    <td>
                        <div class="Validform_checktip" style="height: auto;">
                            输入菜单链接地址，为空时无链接。<br />
                            格式：/admin/system/xx.aspx
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div class="clear">
        </div>
        <div class="aui_buttons" style="height: 35px;">
            <button id="c_ok" class="aui_state_highlight" type="submit" style="float: right;">
                <%=btn_text %>
            </button>
            <input type="hidden" id="C_Order" name="C_Order" value="" />
            <input type="hidden" id="C_ID" name="C_ID" value="" />
        </div>
    </div>
    </form>
</body>
</html>
